package stack.era.presentation.images;

import java.awt.Image;
import java.util.HashMap;

import javax.swing.ImageIcon;

import stack.era.constants.ImageAttributes.ImageCacheName;

public class ImageCache {

	private static ImageCache instance = null;

	private HashMap<ImageCacheName, Image> cache;

	private ImageCache() {
		cache = new HashMap<ImageCacheName, Image>();
		for (ImageCacheName i : ImageCacheName.values()) {
			cache.put(i, new ImageIcon(i.getFilePath()).getImage());
		}
	}

	public static ImageCache getInstance() {
		if (instance == null) {
			instance = new ImageCache();
		}
		return instance;
	}
	
	public Image getImage(ImageCacheName i) {
		return cache.get(i);
	}

}
